package com.sxkiler.demo.controller;

import com.sxkiler.demo.config.RocketMqConsumerConfig;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试其Rebalance功能
 * 通过随机一个堵住
 */
@RestController
@RequestMapping("/mq")
public class TestRocketMqController {

    @RequestMapping(value = "/rebalance" ,method = RequestMethod.GET)
    @ResponseBody
    public void rebalance(){
        DefaultMQPushConsumer consumer = RocketMqConsumerConfig.getConsumer();
        consumer.getDefaultMQPushConsumerImpl().doRebalance();
        consumer.getDefaultMQPushConsumerImpl().adjustThreadPool();
    }
}
